import { Controller, Get, Post, Query } from '@nestjs/common';
import { CategoryService } from "../../services/category/category.service";
import { ApiTags,ApiResponse,ApiQuery, ApiParam } from '@nestjs/swagger';
import { Crud } from '@nestjsx/crud';
import { Category } from "../../entities/category.entity";

@Crud({
  model:{
    type:Category
  },
  query:{
    join:{
      children:{
        exclude:["is_show","show_index","type","parent_id","keywords","level","sort_order","icon_url","img_url"]
      },
      'children.goods':{
        exclude:["category_id","brand_id","keywords","is_on_sale","is_delete","attribute_category","is_new","app_exclusive_price","is_app_exclusive","is_limited","is_hot","create_user_id","update_user_id","create_user_dept_id","promotion_tag","add_time","update_time","counter_price","extra_price","unit_price"],
      }
    },
    exclude:["is_show","show_index","type","parent_id","keywords","level"],
    sort:[
      {
        field:"sort_order",
        order:"ASC"
      }
    ],
    filter:[
      {
        field:"is_show",
        operator:"$eq",
        value:1
      }
    ]
  }
})
@ApiTags('category')
@Controller('api/category')
export class CategoryController {
  constructor(
    public readonly service: CategoryService
  ){}
  
}
